<?php

// phpMyRealty 3
//
// File Name: image.php
// File Location : ./
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

// Include configuration file and general functions
define('PMR', 'true');

include ( './config.php' );
include ( PATH . '/defaults.php' );

// Title tag content
$title = $lang['Photo_Gallery'];

// Include header and tables template
include ( PATH . '/includes/common_header.php' );
include ( PATH . '/templates/' . $cookie_template . '/tables.php'); 

// Do not cache the dynamic output
header("Expires: Mon, 1 Jan 1980 01:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Pragma: no-cache"); // HTTP/1.0

echo '
 <html>
  <head>
   <meta name="author" content="phpMyRealty.com">
   <meta name="copyright" content="Copyright, phpMyRealty.com. All rights reserved.">
   <meta name="title" content="' . $conf['title_meta'] . '">
   <meta name="description" content="' . $conf['description_meta'] . '">
   <meta name="keywords" content="' . $conf['keywords_meta'] . '">

   <meta name="robots" content="' . $conf['robots_meta'] . '">
   <meta name="revisit-after" content="7 days">

   <meta http-equiv="Content-Type" content="text/html; charset=' . $lang['Encoding'] . '">
   <meta http-equiv="Content-Style-Type" content="text/css">
    
   <link rel="stylesheet" href="' . URL . '/templates/' . $cookie_template . '/style.css' . '" type="text/css">

   <title> ' . $title . ' </title>

  </head>

 <body bgcolor="white">
  <table width="100%" cellpadding="5" cellspacing="0" border="0">
   <tr> 
    <td>
     ';

 echo table_header($lang['Photo_Gallery']);

 $sql = 'SELECT * FROM ' . GALLERY_TABLE . ' WHERE id = "' . safehtml ($_GET['id']) . '" LIMIT 1';
 $r = $db->query($sql);
 $f = $db->fetcharray($r);

 $sql = 'SELECT * FROM ' . GALLERY_TABLE . ' WHERE listingid = ' . $f['listingid'] . ' ORDER BY id';
 $r = $db->query($sql);

 // Print the image
 echo '<p align="center"><img src="' . URL . '/' . $_GET['req'] . '/' . intval($_GET['id']) . '.jpg?nocache=' . rand(0, 9999999) . '" alt="" class="images" border="0" onClick="window.close()"><br /><br />';

 $i = 1;

 // Print the gallery pagination

 if ($_GET['req'] == 'gallery')
  {
   while ($f = $db->fetcharray($r))
    {

     if ($_GET['id'] == $f['id'])

      echo '[<strong>' . $i . '</strong>]&nbsp;&nbsp;';

     else

      {
       if ($conf['rewrite'] == 'ON')
        echo '<a href="' . URL . '/Gallery/gallery-' . $f['id'] . '.html">' . $i . '</a>&nbsp;&nbsp;';
       else
        echo '<a href="' . URL . '/image.php?req=gallery&amp;id=' . $f['id'] . '.html">' . $i . '</a>&nbsp;&nbsp;';
      }

     $i++;

    }

  }

 echo '<br /><br />';

 // Print the close button
 echo '<a href="#" onClick="window.close()">' . $lang['Close'] . '</a>&nbsp; | &nbsp;';

 // Print the Print button
 echo '<a href="#" onClick="window.print()">' . $lang['Print'] . '</a>';

 echo '</p>';

 echo table_footer();

echo '
    </td>
   </tr>
  </table>
 </body>
 </html>

     ';
?>